home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 10.9 KB | 343 lines |
- /*
- * DataSource.java 1.0 12 Jan 1997
- *
- * Copyright (c) 1996 Krumel & Associates, Inc. All Rights Reserved.
- *
- * This software is provided as is. Krumel & Associates shall not be liable
- * for any damages suffered by licensee as a result of using, modifying or
- * distributing this software or its derivatives.
- */
-
- package symantec.itools.db.awt;
-
- import java.awt.Image;
-
- /**
- * Interface defines the API required to support storing data for the Grid.<p>
- *
- * All row and column values are 0 relative.
- */
- public interface DataSource {
- /**
- * Sets the Grid displaying the data.
- */
- public void setGrid(Grid v);
-
- /**
- * Gets the grid displaying the data for the DataSource
- */
- public Grid getView();
-
- /**
- * Informs the data source whether the grid will be requesting successive data
- * for read only purposes.
- * @param manual true if the data source should expect read only data requests
- */
- public void fetchMode(boolean manual);
-
- /**
- * Sets the Data type for cell data when no data value has been set.
- */
- public void setDefaultData(Data defaultValue);
-
- /**
- * Requests the DataSource set an appropriate default data type
- */
- public void setDefaultData();
-
- /**
- * Gets whether the DataSource has the ability to configure a Grid
- */
- public boolean supportsMeta();
-
- /**
- * Called by the Grid to configure the interface if the DataSource supports
- * meta information
- * @param v The grid to configure
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested
- */
- public void setupGrid(Grid v) throws TypeNotSupported;
-
- /**
- * Requests the current data element be reset to the previously committed
- * state
- */
- public void rollbackCurrentData();
-
- /**
- * Gets the data for a cell that should only be used for reading. It does
- * not change the cell data being currently edited.
- * @param row the cells row
- */
- public Data readData(int row, int col) throws DataNotAvailable;
-
- /**
- * Gets the data for a cell. If the requested data is not the data being
- * currently edited, the current data should be set to the data requested
- */
- public Data getData(Coordinate coords) throws DataNotAvailable;
-
- /**
- * Gets the data for a cell. If the requested data is not the data being
- * currently edited, the current data should be set to the data requested
- */
- public Data getData(int r, int c) throws DataNotAvailable;
-
- /**
- * Commits the current data.
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void commitData() throws TypeNotSupported;
-
- /**
- * Sets the data value for a cell.
- * @param r the row of the cell
- * @param c the column of the cell
- * @param data the data value for the cell
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void setData(int r, int c, Data data) throws TypeNotSupported;
-
- /**
- * Sets the data value for a cell.
- * @param coord the cooridates of the cell
- * @param data the data value for the cell
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void setData(Coordinate coord, Data data) throws TypeNotSupported;
-
- /**
- * Gets the textual representation of a cell's data
- * @exception DataNotAvailable The requested data is not set in the
- * data source.
- */
- public String getText(Coordinate coords) throws DataNotAvailable;
-
- /**
- * Gets an image representation of a cell's data
- * @exception DataNotAvailable The requested data is not set in the
- * data source.
- */
- public Image getImage(Coordinate coords) throws DataNotAvailable;
-
- /**
- * Deletes or marks a row for deletion from the data source
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void deleteRow(int row) throws TypeNotSupported;
-
- /**
- * Undeletes a row in the data source
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void undeleteRow(int row) throws TypeNotSupported;
-
- /**
- * Inserts a new row in the data source above the specified row
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void insertRow(int row) throws TypeNotSupported;
-
- /**
- * Appends a new row at the end of the data source's data.
- */
- public int appendRow() throws TypeNotSupported;
-
- /**
- * Gets whether the data source supports a specified type of data
- */
- public boolean supports(Coordinate coords, int type);
-
- /**
- * Called in response to circulating an event caused by an invocation of
- * Grid.generateEvent(). The event IDs are specified in the Grid class
- * @return true if the event is handled by the data source.
- */
- public boolean handleEvent(java.awt.Event e);
-
- /**
- * Routes any exceptions generated to the Grid for proper handling which may
- * include putting a message on status bar or logging to a file.
- */
- public void handleException(int row, int col, Exception ex);
-
- /**
- * Requests the data source reread it data.
- */
- public void refresh();
-
- /**
- * Requests the data source remove all data.
- */
- public void clear();
-
- /**
- * Requests the data source save the current state as appopriate.
- */
- public void save() throws TypeNotSupported;
-
- /**
- * Requests that any actions performed on a row be undone. The meaning
- * is left open and is to interpreted as appropriate for the type of
- * data source
- */
- public void undoRow(int row) throws TypeNotSupported;
-
- /**
- * Gets whether a cells data is editable or non-editable
- * @return true if the data may be altered by the user.
- */
- public boolean isDataEditable(int row, int col);
-
- /**
- * Informs the data source of the current row of the Grid.
- */
- public void setCurrentRow(int row) throws TypeNotSupported;
-
- /**
- * The state of the row is new
- */
- public static final int NEW_ROW = 0;
- /**
- * The state of the row is clean (it has been been changed since loaded
- * from some source)
- */
- public static final int CLEAN_ROW = 1;
- /**
- * The row has been marked for deletion.
- */
- public static final int DELETED_ROW = 2;
- /**
- * The row has been modified since creation.
- */
- public static final int MODIFIED_ROW = 3;
-
- /**
- * Gets the state of the row.
- * @return the state of the row's data. One of NEW_ROW, CLEAN_ROW, DELETED_ROW,
- * or MODIFIED_ROW
- */
- public int rowState(int row);
-
- /**
- * Gets the last row valid in requested range
- * @exception DataNotAvailable The requested data is not set in the
- * data source.
- */
- public int validDataRowRange(int top, int bottom) throws DataNotAvailable;
-
- /**
- * Gets the number of rows of data stored in the data source
- */
- public int rows();
-
- /**
- * Requests the data source get all of the rows from its source of data.
- */
- public int fetchAllRows();
-
- //Here are some methods needed to support DefaultData
- /**
- * Method used to support Defaultdata class. Gets the type of data supported
- * by the cell.
- */
- public int type(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Commits the data for the
- * specified cell
- */
- public void commit(int row, int col) throws TypeNotSupported;
-
- /**
- * Method used to support Defaultdata class. Gets whether the data for the
- * specified cell supports choice selection lists.
- */
- public boolean supportsChoice(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Gets the choices for the cell to
- * display.
- */
- public Data[] getChoices(int row, int col) throws TypeNotSupported;
-
- /**
- * Method used to support Defaultdata class. Sets the textual value for a cell.
- */
- public void setText(int row, int col, String t);
- //pos is space where to be inserted (0 = first char)
-
- /**
- * Method used to support Defaultdata class. Inserts a character at the
- * specified location in the data value for a cell.
- * @param row The cell's row
- * @param col The cell's column
- * @param pos The position to insert character
- * @param c The character
- */
- public void insertChar(int row, int col, int pos, char c);
-
- /**
- * Method used to support Defaultdata class. Sets the text for a cell to a
- * character
- */
- public void setText(int row, int col, char c);
-
- /**
- * Method used to support Defaultdata class. Appends a character to the end
- * of the textual representation of the cell's data.
- */
- public void appendChar(int row, int col, char c);
-
- /**
- * Method used to support Defaultdata class. Clears the textual value of a cell.
- */
- public void clearText(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Deletes a character from a cell's
- * data.
- * @param row The cell's row
- * @param col The cell's column
- * @param pos The position to delete character
- */
- public void deleteChar(int row, int col, int pos);
-
- /**
- * Method used to support Defaultdata class. Gets a substring from a cell's
- * data.
- * @param row The cell's row
- * @param col The cell's column
- * @param spos The starting position of the substring, inclusive
- * @param epos The last position of the substring, exclusive
- */
- public String subString(int row, int col, int spos, int epos);
-
- /**
- * Method used to support Defaultdata class. Sets the image data for a cell
- */
- public void setImage(int row, int col, Image i);
-
- /**
- * Method used to support Defaultdata class. Gets a string representation of
- * a cell's data.
- */
- public String toString(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Gets an image representationof
- * a cell's data.
- */
- public Image toImage(int row, int col);
-
- public Object getSynchronizationObject();
- }
-
-